package com.xxx.hhh.demo.demo7;

import java.io.*;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.Socket;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket s = new Socket(InetAddress.getByName("127.0.0.1"),10200);
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\Swimming.png"));
        BufferedOutputStream bos = new BufferedOutputStream(s.getOutputStream());
       byte[] arr = new byte[1024 * 8];
        int b;
        while((b = bis.read(arr))!= -1){
            bos.write(arr,0,b);
            bos.flush();
        }
       s.shutdownOutput();

    //      接收服务端传回的数据
        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        System.out.println(br.readLine());
        br.close();
        bis.close();
        s.close();
    }
}
